/*
 * PlanspielView.java
 */

package planspiel;

import java.awt.BorderLayout;

import javax.swing.JDialog;
import javax.swing.JFrame;

import org.jdesktop.application.Action;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.SingleFrameApplication;

import planspiel.panels.TitleScreen;
import planspiel.panels.WelcomeScreen;

/**
 * The application's main frame.
 */
public final class PlanspielView extends FrameView {
    
    /**
     * 
     * @param app
     */
    public PlanspielView(SingleFrameApplication app) {
        super(app);

        initComponents();
        
        getFrame().setResizable(false);
        
        screen1_titleScreen();
    }
    
    /**
     * 
     */
    public void screen1_titleScreen(){
        mainPanel.removeAll();
        
        BorderLayout layout = new BorderLayout();
        mainPanel.setLayout(layout);
        TitleScreen titleScreen = new TitleScreen();
        titleScreen.setPlanspielView(this);
        titleScreen.paintScreen();
        mainPanel.add(titleScreen, BorderLayout.CENTER);
        mainPanel.validate();
    }
    
    /**
     * 
     */
    public void screen2_welcomeScreen(){
        mainPanel.removeAll();
        
        BorderLayout layout = new BorderLayout();
        mainPanel.setLayout(layout);
        WelcomeScreen welcomeScreen = new WelcomeScreen();
        welcomeScreen.setPlanspielView(this);
        welcomeScreen.paintScreen();
        mainPanel.add(welcomeScreen, BorderLayout.CENTER);
        mainPanel.validate();
    }

    /**
     * 
     */
    public void screen3_gameScreen(){
        new Game(mainPanel, this);
    }    
    
    /**
     * 
     */
    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = PlanspielApp.getApplication().getMainFrame();
            aboutBox = new PlanspielAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        PlanspielApp.getApplication().show(aboutBox);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();

        mainPanel.setName("mainPanel"); // NOI18N

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 279, Short.MAX_VALUE)
        );

        menuBar.setName("menuBar"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(planspiel.PlanspielApp.class).getContext().getResourceMap(PlanspielView.class);
        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(planspiel.PlanspielApp.class).getContext().getActionMap(PlanspielView.class, this);
        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        helpMenu.setName("helpMenu"); // NOI18N

        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        setComponent(mainPanel);
        setMenuBar(menuBar);
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    // End of variables declaration//GEN-END:variables


    private JDialog aboutBox;
}
